package projetofinal.controle;

import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class PlacesOverlay extends ItemizedOverlay<OverlayItem>{
	
	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	protected static final int INSERIR_EDITAR = 1;
	Context mContext;

	public PlacesOverlay(Drawable defaultMarker) {
		super(boundCenterBottom(defaultMarker));
		// TODO Auto-generated constructor stub
	}

	public PlacesOverlay(Drawable defaultMarker, Context context) {
		super(boundCenterBottom(defaultMarker));
		mContext = context;
	}
	
	@Override
	protected OverlayItem createItem(int i) {
		// TODO Auto-generated method stub
		return mOverlays.get(i);
	}
		
	@Override
	public int size() {
		// TODO Auto-generated method stub
		return mOverlays.size();
	}
	
	public void addOverlay(OverlayItem overlay) {
	    mOverlays.add(overlay);
	    populate();
	}
	
	@Override
	public boolean onTap(int index) {

		OverlayItem item = mOverlays.get(index);
		Intent intent = new Intent(mContext , TelaIntermediariaCentro.class);
		intent.putExtra("nomeCentro", item.getSnippet());
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
		mContext.startActivity(intent);
					
		return true;
	}		
}
